<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--${education}--%>
<div class="exper_add" id="exper_add" style="display: block;">
    <p>编辑教育经历</p>
    <table>
        <tr>
            <td colspan="2">
                <div class="layui-inline">
                    <label class="layui-form-label"> 学&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp校</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="schoolName" placeholder="请填写学校"
                               value="${education.schoolName}" style="width: 490px">
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="layui-form-item">
                    <label class="layui-form-label">学&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp历</label>
                    <div class="layui-input-block">
                        <select name="resIdentity" lay-verify="required" id="degree">
                            <option value="大专" <c:if test="${education.major=='大专'}">selected</c:if>>大专</option>
                            <option value="本科" selected<c:if test="${education.major=='本科'}">selected</c:if>>本科
                            </option>
                            <option value="硕士" <c:if test="${education.major=='硕士'}">selected</c:if>>硕士</option>
                            <option value="博士" <c:if test="${education.major=='博士'}">selected</c:if>>博士</option>
                            <option value="其他" <c:if test="${education.major=='其他'}">selected</c:if>>其他</option>
                        </select>
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-inline">
                    <label class="layui-form-label">专&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp业</label>
                    <div class="layui-input-inline">
                        <input type="text" id="major" class="layui-input" placeholder="请填写专业"
                               value="${education.major}">
                    </div>
                </div>
            </td>

        </tr>

        <tr>
            <td colspan="2">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">在校时间</label>
                        <div class="layui-inline" id="test-range">
                            <div class="layui-input-inline">
                                <input type="text" id="startDate" class="layui-input" placeholder="开始时间"
                                       value="<fmt:formatDate value="${education.startDate}" pattern="yyyy-MM-dd"/>"
                                       style="width: 213.4px">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" id="endDate" class="layui-input" placeholder="结束时间"
                                       value="<fmt:formatDate value="${education.endDate}" pattern="yyyy-MM-dd"/>"
                                       style="width: 213.4px">
                            </div>
                        </div>
                    </div>
                </div>
            </td>
            <td></td>
        </tr>
        <tr>
            <td colspan="2">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">在校经历</label>
                    <div class="layui-input-block">
                            <textarea name="desc" id="experienceSchool" placeholder="请输入内容"
                                      class="layui-textarea">${education.experienceSchool}</textarea>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <button class="button_save" value="${education.id}" onclick="button_edu_save(this.value)">保存并更新</button>
    <button class="button_cancel" id="button_edu_cancel">取消</button>
</div>
<script>

    function button_edu_save(obj) {
        console.log(obj)
        let resumeId = $("#resumeId").val();
        // let educationId = $("#educationId").val();
        let educationId = obj;
        console.log(educationId)
        //学校名称
        let schoolName = $("#schoolName").val();
        console.log(schoolName);
        //学历
        let degree = $("#degree option:selected").val();
        console.log(degree);
        //专业
        let major = $("#major").val();
        console.log(major);
        //在校时间 - 开始
        let startDate = $("#startDate").val();
        console.log(startDate);
        //在校时间 -结束
        let endDate = $("#endDate").val();
        console.log(endDate);
        //在校经历
        let experienceSchool = $("#experienceSchool").val();
        console.log(experienceSchool);
        // let param = "id=" + educationId + "&schoolName=" + schoolName
        //     + "&degree=" + degree + "&major=" + major + "&startDate=" + startDate + "&endDate=" + endDate + "&experienceSchool=" + experienceSchool;
        // console.log(param);
        $.post('/hire/resume/education/update', {
            id: educationId,
            schoolName: schoolName,
            degree: degree,
            major: major,
            startDate: startDate,
            endDate: endDate,
            experienceSchool: experienceSchool
        }, function (res) {
            if (res.code == '200') {
                $("#edu_info").load("/hire/resume/edu_info", {id: resumeId, educationId: educationId});
                $("#edu_edit").hide();
                $("#edu_info").show();
            } else {
                layer.msg(res.msg);
            }
        })
    }

    $("#button_edu_cancel").click(function () {
        let resumeId = $("#resumeId").val();
        $("#edu_info").load("/hire/resume/edu_info", {id: resumeId});
        $("#edu_edit").hide();
        $("#edu_info").show();
    })
    layui.use('laydate', function () {
        let laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素

        });
    });
    layui.use('laydate', function () {
        let laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#endDate' //指定元素
        });
    });

</script>